<% breadcrumb :dashboard_invoices %>

<div class="dashboard-invoices-index">
    <div class="row menu-list-row">
        <div class="col-sm-3">
            <%= render partial: 'dashboard/left_menu' -%>
        </div>

        <div class="col-sm-9">
            <h3>我的发票管理</h3>
            <div class="panel">
                <div class="panel-body padding-reset">
                    <div class="well tip-well text-gray">
                        1.开发票请先填写开票信息。增值税普通发票填写后即可开票，增值税专用发票需审核后才可开票。审核需要 3~6 个工作日。
                        <br>
                        2.每月前 3 个工作日为账期，在此期间的申请需等到当月第 4 个工作日方可开票。
                        <br>
                        3.订单完成后请尽快申请开票，超过 6 个月未申请开票的订单将不可开票。
                        <br>
                        4.申请发票金额小于 100 元需支付快递费。
                    </div>

                    <div class="well column-well" style="font-weight: bold;">
                        <div class="row">
                            <div class="col-xs-5">订单详情</div>
                            <div class="col-xs-2">发票类型</div>
                            <div class="col-xs-3">发票内容</div>
                            <div class="col-xs-2">操作按钮</div>
                        </div>
                    </div>

                    <% @orders.each do |order| %>
                      <div class="row margin-reset item">
                          <div class="row margin-reset">
                              <div class="col-xs-12">
                                  订单编号：<span class="text-gray"><%= order.order_no %></span>
                              </div>
                          </div>
                          <div class="row margin-reset column-col">
                              <div class="col-xs-5 title-and-img">
                                  <% if order.order_items.present? && order.order_items.first.product.present? %>
                                    <%= product_small_img_1(order.order_items.first.product, 'product-img') %>
                                    <div class="title">
                                        <%= order.order_items.first.product.title %>
                                    </div>
                                  <% else %>
                                    <img src="<%= image_path('default_product.png') %>" class="product-img">
                                    <div class="title">
                                      <%= order.reserve.survey_fee.name %>
                                    </div>
                                  <% end %>
                              </div>
                              <% if invoice=order.invoice %>
                                  <div class="col-xs-2">
                                      <%= get_invoice_type_str(invoice) %>
                                  </div>
                                  <div class="col-xs-3">
                                      <div class="text-red">￥<%= order.total_money %></div>
                                      <div><%= invoice.title %></div>
                                  </div>
                                  <div class="col-xs-2">
                                    <a href="#">已开票</a>
                                  </div>
                              <% else %>
                                  <div class="col-xs-2">
                                      暂未开票
                                  </div>
                                  <div class="col-xs-3">
                                      暂未开票
                                  </div>
                                  <div class="col-xs-2">
                                    <a href="<%= new_dashboard_invoice_path(order_id: order.id) %>" class="btn btn-primary">申请发票</a>
                                  </div>
                              <% end %>
                          </div>
                      </div>
                    <% end %>
                </div>
            </div>
            <%= common_paginate @orders %>
        </div>
    </div>
</div>
